﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Data;
using System.Configuration;

namespace WebApplication1
{
    public partial class NavigationResult : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            if (Request.QueryString["TagName"] == null)
                Response.Redirect("~/Search.aspx");

            if (!IsPostBack)
            {
                tbxSearch.Attributes.Add("onclick", "this.value=''");
                InitPanelSourceDownload();
                InitPanelEducationNews();
                InitPanelReferenceBooks();
            }
        }

        private void InitPanelSourceDownload()
        {
            DataTable dt = new DataTable();
            string TagName = Request.QueryString["TagName"];
            SQLHelper.getTopFileUploadBelongTagName(out dt, TagName, 10);
            RepeaterDownLoad.DataSource = dt;
            RepeaterDownLoad.DataBind();
        }

        private void InitPanelEducationNews()
        {
            DataTable dt = new DataTable();
            string TagName = Request.QueryString["TagName"];
            SQLHelper.getTopNewsBelongTagName(out dt, TagName, 10);
            RepeaterNews.DataSource = dt;
            RepeaterNews.DataBind();
        }

        private void InitPanelReferenceBooks()
        {
            DataTable dt = new DataTable();
            string TagName = Request.QueryString["TagName"];
            SQLHelper.getBookBelongTagName(out dt, TagName);
            RepeaterBook.DataSource = dt;
            RepeaterBook.DataBind();
        }

        protected void ibtMoreDownload_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect("MoreDownload.aspx?TagName="+Request.QueryString["TagName"]);
        }

        protected void ibtMoreNews_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect("MoreNews.aspx?TagName=" + Request.QueryString["TagName"]);
        }

        protected void ibSearch_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect("~/Search.aspx?text=" + tbxSearch.Text);
        }

        
    }
}